<!DOCTYPE html>
<!-- templates -->
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Cloud Recording</title>
    <script src="./edu_sdk.bundle.js"></script>
  </head>

  <body>
    <style>
      #root1 {
        width: 100%;
        height: 100%;
      }
    </style>
    <div id="root1"></div>
    <script type="text/javascript">
      function useParams(location) {
        const searchString = location.href.split('?').pop();
        const urlParams = new URLSearchParams(location.href.split('?').pop());
        const audienceParams = {};
        for (let key of urlParams.keys()) {
          audienceParams[key] = urlParams.get(key);
        }
        console.log('urlParams ', audienceParams);
        return audienceParams;
      }

      const {
        // appId,
        // userUuid,
        // userName,
        // roomUuid,
        // userRole,
        // roomType,
        // roomName,
        // pretest = false,
        // rtmUid,
        // rtmToken,
        // language,
        // translateLanguage = 'auto',
        // startTime,
        // duration,
        // courseWareList = [],
        // personalCourseWareList = [],
        userUuid,
        userName,
        roomUuid,
        roleType,
        roomType,
        roomName,
        pretest,
        rtmUid,
        rtmToken,
        language,
        startTime,
        duration,
        recordUrl,
        appId,
        userRole,
        translateLanguage,
        region,
      } = useParams(window.location);

      // const options = paramsObject
      // if(!options) {
      //     document.querySelector("#root1").textContent = "options missing"
      // } else {
      //AgoraEduSDK.setParameters()
      AgoraEduSDK.setParameters(
        JSON.stringify({
          host: `https://api.sd-rtn.com`,
        }),
      );
      AgoraEduSDK.config({
        appId,
        cachePath: undefined,
        region: region ? region : 'CN',
      });
      AgoraEduSDK.launch(document.querySelector('#root1'), {
        userUuid,
        userName,
        roomUuid,
        roleType: Number(roleType),
        roomType: Number(roomType),
        roomName,
        pretest: false,
        rtmUid,
        rtmToken,
        language,
        startTime,
        duration,
        recordUrl,
        appId,
        userRole,
        // translateLanguage: language,
        courseWareList: [],
        listener: (evt, args) => {
          console.log('evt', evt, args);
        },
      }).then(() => {
        console.log('start launch');
      });
      // }
    </script>
  </body>
</html>
